package com.st.controller;

import com.st.base.BaseResult;
import com.st.comment.MessageComment;
import com.st.service.GoodsDetailService;
import com.st.vo.GetGoodsDetailListForIndex_1Vo;
import com.st.vo.GetGoodsDetailListForIndex_2Vo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/*
商品分类控制器
 */
@Tag(name="商品分类控制器",description = "此控制器管理所有关于商品分类的接口")
@RestController
@RequestMapping(path = "goodsDetail")
public class GoodsDetailController {
    @Autowired
    private GoodsDetailService goodsDetailService;

    /*
    1.获取小程序首页分类简述列表
     */
    @Operation(summary = "获取小程序首页分类简述列表(轮播图下面的列表)")
    @RequestMapping(path = "getGoodsDetailListForIndex_1",method = RequestMethod.GET)
    public BaseResult<List<GetGoodsDetailListForIndex_1Vo>> getGoodsDetailListForIndex_1(){
        List<GetGoodsDetailListForIndex_1Vo>  goodsDetailListForIndex1 = goodsDetailService.getGoodsDetailListForIndex_1();
        return goodsDetailListForIndex1 != null && goodsDetailListForIndex1.size() > 0 ? BaseResult.ok(goodsDetailListForIndex1) : BaseResult.error(MessageComment.DATA_NOT_FOUND);
    }


    /*
    2.获取小程序首页主推分类列表（4个主推类型）
     */
    @Operation(summary = "获取小程序首页主推分类列表（4个主推类型）")
    @Parameters(
            {
                    @Parameter(name = "pageNumber",description = "页码",required = false),
                    @Parameter(name = "pageSize",description = "页容量",required = false)
            }
    )
    @RequestMapping(path = "getGoodsDetailListForIndex_2",method = RequestMethod.GET)
    public BaseResult<List<GetGoodsDetailListForIndex_1Vo>> getGoodsDetailListForIndex_2(
            @RequestParam(name = "pageNumber",required = false,defaultValue = "1") Integer pageNumber,
            @RequestParam(name = "pageSize",required = false,defaultValue = "4") Integer pageSize
    ){
        List<GetGoodsDetailListForIndex_2Vo> goodsDetailListForIndex2 = goodsDetailService.getGoodsDetailListForIndex_2(pageNumber,pageSize);
        return goodsDetailListForIndex2 != null && goodsDetailListForIndex2.size() > 0 ? BaseResult.ok(goodsDetailListForIndex2) : BaseResult.error(MessageComment.DATA_NOT_FOUND);
    }
}
